package hydrap2p.search;

import java.util.List;
import java.util.Map.Entry;

public class ListenerAllSyncerator implements Runnable{

	private ListenerIface listener;
	private Searches searches;
	public ListenerAllSyncerator(ListenerIface listener, Searches searches)
	{
		this.listener=listener;
		this.searches=searches;
	}

	@Override
	public void run() {
		for (Entry<Integer, Search> entry:searches.getSearches().entrySet())
		{
			try {
				List<String> providers=entry.getValue().getSearchTotalProviders();
				listener.newSearch(entry.getKey(), entry.getValue().getSearchQuery(), providers);

			} catch (Exception e) {
				// Failed to notify the listener, he must've died
				return;
			}
		}
	}

}
